<script setup>
import { ref, watch } from 'vue';

const count = ref(0)
const name= ref('老韩')
const add = () => {
  count.value++
}
const changeName = () => {
  name.value = '小韩'
}
watch([count, name], ([newCount, newName], [oldCount, oldName]) => {
  console.log(`count发生了变化, 老值为${oldCount}--${oldName}, 新值为${newCount}--${newName}`)
})
</script>

<template>
  <div class="app-page">
    {{ count }}-- {{ name }}
    <button @click="add">加一</button>
    <button @click="changeName">变小</button>
  </div>
</template>

<style scoped></style>
